package com.four.commodity.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.four.commodity.service.CommodityService;
import com.four.commodity.service.impl.CommodityServiceImpl;

@WebServlet("/deleteCommodity.do")
public class DeleleCommodityServiet extends HttpServlet {
//删除功能
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String id = req.getParameter("id");
		CommodityService service = new CommodityServiceImpl();
		boolean result = service.deleteCommodity(id);
		PrintWriter pw = resp.getWriter();
		pw.append(String.valueOf(result));
		pw.flush();
		pw.close();
		
		}
}
